/**
 * 系统设置相关类型定义
 * 与后端API接口保持一致
 */

// 基本设置接口
export interface GeneralSettings {
  system_name: string
  system_description: string
  system_version: string
  timezone: string
  language: string
  theme: string
}

// 安全设置接口
export interface SecuritySettings {
  password_min_length_enabled: boolean
  password_min_length: number
  password_require_uppercase: boolean
  password_require_lowercase: boolean
  password_require_numbers: boolean
  password_require_symbols: boolean
  session_timeout_enabled: boolean
  session_timeout_minutes: number
  login_attempts_enabled: boolean
  max_login_attempts: number
}

// 通知设置接口
export interface NotificationSettings {
  email_enabled: boolean
  smtp_host: string
  smtp_port: number
  smtp_username: string
  smtp_password: string
  smtp_encryption: 'none' | 'tls' | 'ssl'
  notify_task_assigned: boolean
  notify_task_completed: boolean
  notify_project_update: boolean
  notify_deadline_reminder: boolean
}

// 系统配置接口
export interface SystemSettings {
  max_file_size_mb: number
  allowed_file_types: string
  db_pool_size: number
  db_query_timeout: number
  cache_enabled: boolean
  cache_ttl_minutes: number
  log_level: 'debug' | 'info' | 'warning' | 'error'
  log_retention_days: number
}

// 备份设置接口
export interface BackupSettings {
  auto_backup_enabled: boolean
  backup_frequency: 'daily' | 'weekly' | 'monthly'
  backup_time: string
  max_backup_count: number
  backup_compression: boolean
  backup_encryption: boolean
}

// 系统设置响应接口
export interface SystemSettingsResponse {
  general: GeneralSettings
  security: SecuritySettings
  notification: NotificationSettings
  system: SystemSettings
  backup: BackupSettings
  updated_at?: string | null
  updated_by?: string | null
}

// 备份记录接口
export interface BackupRecord {
  id: string
  filename: string
  size: number
  status: 'running' | 'success' | 'failed' | 'unknown'
  created_at: string
  created_by?: string | null
}

// 备份记录列表接口
export interface BackupRecordList {
  items: BackupRecord[]
  total: number
}

// 邮件测试请求接口
export interface EmailTestRequest {
  to_email: string
  subject: string
  content: string
}

// 设置更新请求接口
export interface GeneralSettingsUpdate extends Partial<GeneralSettings> {}
export interface SecuritySettingsUpdate extends Partial<SecuritySettings> {}
export interface NotificationSettingsUpdate extends Partial<NotificationSettings> {}
export interface SystemSettingsUpdate extends Partial<SystemSettings> {}
export interface BackupSettingsUpdate extends Partial<BackupSettings> {}